package cn.renxuan.service.weather.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import cn.renxuan.entity.FS_DomesticWeather;
import cn.renxuan.service.weather.json.BaiduApiBase;
import cn.renxuan.service.weather.json.BaiduWeather;

@Mapper
public interface BaiduWeatherMapper {
    BaiduWeatherMapper INSTANCE = Mappers.getMapper(BaiduWeatherMapper.class);

    @Mapping(source = "result.location.id", target = "countycode")
    @Mapping(source = "result.now.wind_dir", target = "winddirection")
    @Mapping(source = "result.now.wind_class", target = "windpower")
    @Mapping(source = "result.now.text", target = "weather")
    @Mapping(source = "result.now.temp", target = "temperature")
    @Mapping(source = "result.now.rh", target = "humidity")
    @Mapping(source = "result.now.vis", target = "njd")
    @Mapping(source = "result.now.prec_1h", target = "rain1h")
    @Mapping(source = "result.now.uptime", target = "reporttime")
    FS_DomesticWeather toDomesticWeather(BaiduApiBase<BaiduWeather> baiduWeather) throws Exception;
}
